package com.cloud.bc.controller;

import com.cloud.bc.model.domain.UserInfo;
import com.cloud.bc.model.response.TeamCountResponse;
import com.cloud.bc.service.BcSingleContactsService;
import com.cloud.bc.service.BcSinglesService;
import com.cloud.bc.service.BcUsersService;
import com.cloud.common.security.AES;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 推荐好友
 */
@Controller
@RequestMapping("m/center/marketing")
@AllArgsConstructor
public class MCenterMarketingController extends BaseController {
    private final BcUsersService bcUsersService;
    private final BcSinglesService bcSinglesService;
    private final BcSingleContactsService bcSingleContactsService;

    /**
     * 推荐好友
     */
    @GetMapping("")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request, "推荐好友", "m/center/marketing/index");
        UserInfo userInfo = bcUsersService.getUserInfo(request);
        String encodeEid = bcSinglesService.getEidEncode(userInfo.getId().toString());
        view.addObject("eid", encodeEid);
        return view;
    }

    /**
     * 我推荐的人
     */
    @GetMapping("team")
    public ModelAndView team(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request, "我推荐的人", "m/center/marketing/team");
        UserInfo userInfo = bcUsersService.getUserInfo(request);
        TeamCountResponse teamCountResponse = bcSinglesService.getTeamCount(userInfo.getId());
        view.addObject("teamCount", teamCountResponse);
        return view;
    }

}

